package xFramework.extension;

import java.io.FileWriter;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

import net.sf.json.JSONArray;

import org.apache.struts2.ServletActionContext;
import org.json.JSONException;
import org.json.JSONObject;

import xFramework.ibatis.SqlMapInstance;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.opensymphony.xwork2.ActionSupport;

public class XFrameworkSupport extends ActionSupport{

	protected SqlMapClient sqlMap;		

	
    public XFrameworkSupport()
    {
        super();
        sqlMap = SqlMapInstance.getInstance();        
    } 
    
    public SqlMapClient getSqlMap() {
    	return sqlMap;
    }
    
    public void writeJSONResponse(JSONObject objJSON) throws IOException, JSONException {
    	ServletActionContext.getResponse().setCharacterEncoding("UTF-8");
        ServletActionContext.getResponse().setContentType("text/plain");
    	objJSON.write(ServletActionContext.getResponse().getWriter());
    }
    
    public void writeJSONResponse(JSONArray arrJSON) throws IOException {
    	ServletActionContext.getResponse().setCharacterEncoding("UTF-8");
        ServletActionContext.getResponse().setContentType("text/plain");
        arrJSON.write(ServletActionContext.getResponse().getWriter());
    }
    
}
